
# Python imports
import subprocess
import os
import socket

# Ping function
def ping(IP):

	# Perform the ping
	ret = subprocess.call("ping -c 1 -w 1 %s" % IP,
			shell=True,
			stdout=open('/dev/null', 'w'),
			stderr=subprocess.STDOUT)
			
	# Return
	if ret == 0:
		return True
	else:
	    return False

# Resolve an ip from a hostname
def GetIP(hostname):
	
	# Resolve
	ip = socket.gethostbyname(hostname)
	
	# Return
	return ip

